import React, { Component } from "react";
import PropTypes from "prop-types"
import Item from "../Item";
import "./index.css";

export default class List extends Component {

  //添加props验证
  static propTypes= {
    changeTodo: PropTypes.func.isRequired,
    delTodo: PropTypes.func.isRequired,
    todos: PropTypes.array.isRequired
  }

  render() {
    const { todos, changeTodo, delTodo } = this.props;
    return (
      <ul className="list-ul-box">
        {
          todos.map((item, index) => {
            return <Item key={item.id} {...item} index={index} changeTodo={changeTodo} delTodo={delTodo}/>
          })
        }
      </ul>
    );
  }
}
